home *** CD-ROM | disk | FTP | other *** search
/ Gekkan Dennou Club 140 / Gekkan Dennou Club - 2000.1 Vol. 140 (Japan).7z / Gekkan Dennou Club - 2000.1 Vol. 140 (Japan) (Track 1).bin / tools / dshell / dsh333bs.lzh / disp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-12-05  |  5.7 KB  |  312 lines

  1. /*
  2.     dshell    v3
  3.  
  4.     本文表示関係
  5. */
  6.  
  7. #include    "dsh.h"
  8.  
  9.  
  10. static uchar *print_job24(uchar *, int);
  11. static uchar *print_job12(uchar *);
  12.  
  13.  
  14. /*
  15.     一行表示ルーチン
  16. */
  17. void 
  18. p_lin(int lin, int pl)
  19. {
  20.     uchar *ptr;
  21.     int in;
  22.  
  23.     /* cut ↓ */
  24.     int cut_no, cut_line;
  25.     /* cut ↑ */
  26.  
  27.     FNTADR_TABLE *font16P;
  28.  
  29. #ifdef DEBUG
  30.     {
  31.         char    *tbf[40];
  32.         sprintf(tbf,"lhp=%x:lin=%d,pl=%d:lhp[lin]=%x",lhp,lin,pl,(lhp+lin));
  33.         w_open();
  34.         w_mes(0,tbf);
  35.         w_mes(1,"hit any key");
  36.         w_wait(0);
  37.     }
  38. #endif
  39.  
  40.  
  41.     B_LOCATE(0, pl + 1);
  42.     B_COLOR(3);
  43.     B_ERA_AL();
  44.  
  45.     if (lin < 0 || lin >= lpmx) {
  46.         return;
  47.     }
  48.  
  49.     /*
  50.     !    一つ上の行に24dot表示指示があった時の、24dot下半分表示の処理
  51.     */
  52.     if (lin > 0) {
  53.         ptr = lhp[lin - 1];
  54.         while (in = dinstr(ptr, LARGE_IDSTR)) {
  55.             int px, py;
  56.             uchar c;
  57.  
  58.             ptr += in - 1 + 2;        // ptr:'<DEL>W' の直後
  59.             px = (*ptr++ - NUM_BIAS) << 3;
  60.             py = (pl + 1) << 4;
  61.  
  62.             curColor = *ptr++ - NUM_BIAS;
  63.             tcolor(curColor);
  64.             while ((c = *ptr++) != NORM_CHAR)  {    /* 24dot下半分の表示 */
  65.                 int cc;
  66.                 int copl;
  67.                 struct FNTBUF buf, *bufp;
  68.  
  69.                 if (c == '\x1b' && (cc = isEscSeq(ptr))) {
  70.                     ptr += cc;
  71.                     tcolor(curColor);
  72.                     continue;
  73.                 }
  74.                 cc = c;
  75.                 if (iskanji1(c))
  76.                     cc = (cc << 8) + *ptr++;
  77.                 FNTGET(12, cc, &buf);
  78.                 buf.yl = 12;
  79.                 copl = (buf.xl == 12) ? 24 : 36;    /* 横12dot/24dotの場合 */
  80.                 bufp = (struct FNTBUF *)((char *)&buf + copl);
  81.                 bufp->yl = buf.yl;
  82.                 bufp->xl = buf.xl;
  83.                 TEXTPUT(px, py, bufp);
  84.                 px += bufp->xl;
  85.             }
  86.             tcolor(0);
  87.         }
  88.     }
  89.  
  90.  
  91.     /*
  92.     !    現在行の処理
  93.     */
  94.     B_LOCATE(0, pl + 1);
  95.  
  96.     ptr = lhp[lin];
  97.     if (*ptr == CTRL_CHAR) {
  98.         if (debugMode && *(ptr + 1) == VEXEC_CHAR) {
  99.             int colorBak = B_COLOR(2);
  100.             B_PUTC(L'◎');
  101.             ptr += 2;
  102.             B_COLOR(colorBak);
  103.         } else if ((*(ptr + 1) | 0x20) == VEXEC_CHAR) {
  104.             B_PUTC(L'◎');
  105.             ptr += 2;
  106.         } else if  (*(ptr + 1) == HR_CHAR) {
  107.             ptr += 2;
  108.         }
  109.     }
  110.     font16P = &defFont16;
  111.     while (*ptr && (in = dinstrchr(ptr, CTRL_CHAR))) {
  112.         int px;
  113.         uchar *p;
  114.  
  115.         p = ptr;
  116.         ptr += in;
  117.         *--ptr = '\0';
  118.         B_PRINT(p);
  119.         *ptr++ = CTRL_CHAR;
  120.  
  121.         switch (*ptr++) {
  122.         case LARGE_CHAR:
  123.             ptr = print_job24(ptr, pl);
  124.             break;
  125.         case SMALL_CHAR:
  126.             ptr = print_job12(ptr);
  127.             break;
  128.         case CUT_CHAR:
  129.             cut_no = (*ptr++ - NUM_BIAS) << 6;
  130.             cut_no += *ptr++ - NUM_BIAS;
  131.             cut_line = *ptr++ - NUM_BIAS;
  132.             px = *ptr++ - NUM_BIAS;
  133.             tcolor(-1);
  134.             px += cut_print(px * 8, pl * 16 + 16, &(cut[cut_no]), cut_line);
  135.             tcolor(0);
  136.             B_LOCATE(px, pl + 1);
  137.             break;
  138.         case BOX_CHAR:
  139.             {
  140.                 int x, y, xy = B_LOCATE(-1, -1), colorBak;
  141.                 ushort cc;
  142.  
  143.                 y = lowWord(xy);
  144.                 x = *ptr++ - NUM_BIAS;
  145.                 B_LOCATE(x, y);
  146.                 colorBak = B_COLOR(*ptr++ - NUM_BIAS);
  147.                 cc = *ptr++;
  148.                 cc = (cc << 8) | *ptr++;
  149.                 B_PUTC(cc);
  150.                 B_RIGHT(*ptr++ - NUM_BIAS);
  151.                 cc = *ptr++;
  152.                 cc = (cc << 8) | *ptr++;
  153.                 B_PUTC(cc);
  154.                 B_LOCATE(highWord(xy), y);
  155.                 B_COLOR(colorBak);
  156.             }
  157.             break;
  158.         case FONT_CHAR:
  159.             {
  160.                 FNTADR_TABLE *fp;
  161.                 int fontNo;
  162.  
  163.                 if ((fp = malloc(sizeof(FNTADR_TABLE))) != NULL) {
  164.                     *fp = *font16P;
  165.                     fp->prev = font16P;
  166.                     font16P = fp;
  167.                     while ((fontNo = *ptr++) != NORM_CHAR) {
  168.                         fontNo -= NUM_BIAS;
  169.                         if (font16[fontNo].size > 0) {
  170.                             uchar *pat = font16[fontNo].pat;
  171.                             if (font16[fontNo].sect == 0) {
  172.                                 fp->table[0] = pat;
  173.                             } else {
  174.                                 int n;
  175.                                 uchar **p = &fp->table[font16[fontNo].sect];
  176.                                 for (n = font16[fontNo].size; --n >= 0;) {
  177.                                     *p++ = pat;
  178.                                     pat += 32*94;
  179.                                 }
  180.                             }
  181.                         }
  182.                     }
  183.                     setFont16(font16P);
  184.                 } else {
  185.                     while ((fontNo = *ptr++) != NORM_CHAR)
  186.                         ;
  187.                 }
  188.             }
  189.             break;
  190.         case EFONT_CHAR:
  191.             if (font16P->prev != NULL) {
  192.                 FNTADR_TABLE *fp = font16P;
  193.                 font16P = font16P->prev;
  194.                 free(fp);
  195.                 if (font16P->prev == NULL) {
  196.                     setFont16(NULL);
  197.                     setHanFont16(defFont16.table[0]);
  198.                 } else {
  199.                     setFont16(font16P);
  200.                 }
  201.             }
  202.             break;
  203.         case TYPE_CHAR:
  204.             B_PRINT(--ptr);
  205.             px = B_PUTC('>');
  206.             if (highWord(px) > CWIDTH) {
  207.                 B_LOCATE(CWIDTH - 2, lowWord(px));
  208.                 B_PUTC(L'…');
  209.             }
  210.             goto RETURN;
  211.         case NULTYPE_CHAR:
  212.             goto RETURN;
  213.         default:
  214.             B_PRINT(--ptr);
  215.             goto RETURN;
  216.         }
  217.     }
  218.     if (*ptr)
  219.         B_PRINT(ptr);
  220. RETURN:
  221.     if (font16P->prev != NULL) {
  222.         while (font16P->prev != NULL) {
  223.             FNTADR_TABLE *fp = font16P;
  224.             font16P = font16P->prev;
  225.             free(fp);
  226.         }
  227.         setFont16(NULL);
  228.         setHanFont16(defFont16.table[0]);
  229.     }
  230. }
  231.  
  232. /*
  233.     24ドット表示
  234. */
  235. static uchar *
  236. print_job24(uchar *ptr, int pl)
  237. {
  238.     int px, py;
  239.     int cnt, cnt2;
  240.     int i;
  241.  
  242.     struct FNTBUF buf;
  243.     uchar c;
  244.  
  245.     px = (*ptr++ - NUM_BIAS) * 8;    /* ビットマップ座標を得る→X */
  246.     py = (pl + 1) * 16 + 4;    /*            →Y */
  247.     tcolor(*ptr++ - NUM_BIAS);
  248.     cnt2 = 0;
  249.     while ((c = *ptr++) != NORM_CHAR) {    /* 24dot上半分の表示 */
  250.         int cc;
  251.  
  252.         if (c == '\x1b' && (cc = isEscSeq(ptr))) {
  253.             c = *(ptr + cc);
  254.             *(ptr + cc) = '\0';
  255.             B_PRINT(ptr - 1);
  256.             ptr += cc;
  257.             *ptr = c;
  258.             tcolor(curColor);
  259.             continue;
  260.         }
  261.         cc = c;
  262.         if (iskanji1(c))
  263.             cc = (cc << 8) + *ptr++;
  264.         FNTGET(12, cc, &buf);
  265.         buf.yl = 12;
  266.         TEXTPUT(px, py, &buf);
  267.         px += buf.xl;
  268.         cnt2 += buf.xl;    /* buf.xl= 12 or 24 */
  269.     }
  270.     tcolor(0);
  271.     cnt += (cnt2 + 12) / 24;
  272.     if (i = (cnt2 + 7) / 8)
  273.         B_RIGHT(i);
  274.  
  275.     return ptr;
  276. }
  277.  
  278. /*
  279.     12ドット表示
  280. */
  281. static uchar *
  282. print_job12(uchar *ptr)
  283. {
  284.     int n;
  285.  
  286.     n = dinstrchr(ptr, NORM_CHAR);
  287.     if (n > 0) {
  288.         ptr[--n] = '\0';
  289.         B_PRINT12(ptr);
  290.         ptr += n;
  291.         *ptr++ = NORM_CHAR;
  292.     }
  293.     return ptr;
  294. }
  295.  
  296. /*
  297.     画面全体を表示
  298. */
  299. void 
  300. p_scr()
  301. {
  302.     int i, n = lp;
  303.  
  304.     for (i = 32; i < 32 + 30; i++)
  305.         p_lin(n++, i);
  306.     vsync();
  307.     if (GMODE == 0)
  308.         dpalet(0, gr_col[0]);
  309.     dpalet(-3, tx_col[3]);
  310.     TXRASCPY(0x8404, 16/4*30, 0x0003);
  311. }
  312.